package com.qiuhui.spring_boot_06.Controller;

import com.qiuhui.spring_boot_06.Pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;



/**
 * @ClassName: UserController
 * @Description: TODO
 * @author: tian
 * @date: 2021/4/6  11:00 上午
 */
@Controller
public class UserController {
    @RequestMapping(value = "/spring",method = {RequestMethod.GET})
    public String getThymeleaf(Model model){
        model.addAttribute("content","this is spring.");
        return "index";
    }
    @RequestMapping(value = "/user",method = {RequestMethod.GET})
    public String showUser(Model model){
//        User user = new User(10002,"cat",2);
        User user = new User();
        user.setId(1002);
        user.setName("cat");
        user.setAge(8);
        model.addAttribute("user",user);
        return "userInfo";
    }

    @RequestMapping(value = "/link")
    public String showLink(){
        return "link";
    }

    @RequestMapping("/inter")
    public String showIntel(){
        return "international";
    }

    @RequestMapping("/opera")
    public String showOperation(){
        return "operation";
    }

    @RequestMapping("/userMap")
    public String showUserMap(Model model){
        ArrayList<User> users = new ArrayList<>();
        users.add(new User(1001,"jean",6));
        users.add(new User(1003,"lisa",12));
        users.add(new User(1006,"kitty",8));
        model.addAttribute("users",users);
        return "userMap";
    }
}
